﻿(function () {
    'use strict';
    var skillTypeEditController = function ($scope, $routeParams, skillTypeFactory, $location) {
        $scope.skillType = {
            name: ""
        };

        function init() {
            console.log("skillTypeEditController.init");

        }

        $scope.saveSkillType = function () {
            var newSkillType = {
                Name: $scope.skillType.name
            };
            skillTypeFactory.addSkillType(newSkillType)
            .then(function(response) {
                console.log(response);
                $location.path('/joesweb/skillTypes');
            }, function (response) {
                console.log(response);
            });
        };

        $scope.backToSkillTypes = function() {
            $location.path('/joesweb/skillTypes');
        };

        init();
        
    };

    skillTypeEditController.$inject = ['$scope', '$routeParams', 'skillTypeFactory', '$location'];
    angular.module('app')
        .controller('SkillTypeEditController', skillTypeEditController);
}());